package com.lorenzogao.lib_view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;

import java.util.Random;

/**
 * create by LorenzoGao
 * email: 2508719070@qq.com
 * TIME: 2019-11-15 11:17
 * description:
 */

public class BubbleView extends View {


    private int bigRound = 100;
    private int smallRound = 40;

    public BubbleView(Context context) {
        super(context);
    }

    public BubbleView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public BubbleView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);


    }


    @Override
    public void draw(Canvas canvas) {
        super.draw(canvas);

        Paint paint = new Paint();
        paint.setColor(Color.YELLOW);

        Random random = new Random();

        Point centnt = new Point();


        for (int i = 0; i < 5; i++) {
            float randomX = (float) ((random.nextInt(getWidth()) - bigRound)); // 随机生成圆心横坐标（100至200）
            float randomY = (float) ((random.nextInt(getHeight()) - bigRound)); // 随机生成圆心纵坐标（100至200）
            // 随机生成圆的半径（20至60）
            Log.e("TAG","randomY=====>"+randomX+"randomY===="+randomY);
            canvas.drawCircle(randomX, randomY, bigRound, paint);
//            randomX = (float) (smallRound + random.nextInt(1000)); // 随机生成圆心横坐标（100至200）
//            randomY = (float) (smallRound + random.nextInt(1000)); // 随机生成圆心纵坐标（100至200）
//            canvas.drawCircle(randomX, randomY, smallRound, paint);
        }


//        canvas.drawCircle(300,300,100,paint);
//        canvas.drawCircle(600,600,100,paint);


    }
}
